<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
	<%@ include file="/common/query.jsp"%>
<script>
        $(function(){
			var height =($(window).height()-$('fieldset').height()-50);
            $('#members').html('<iframe  id="memIf"  src="${base}/member?fenpeiView=true"  width="100%" height="'+ height +'px"  frameborder="0"></iframe>');
            $('#guwen').html('<iframe id="guwenIf"   src="${base}/system/user?fenpeiView=true"  width="100%" height="'+ height +'px"  frameborder="0"></iframe>');
        });
        function zhixing() {
			var members = $('#memIf')[0].contentWindow.getGridChecked();
			if(members.length==0){
			    alert("请先选择会员");
			    return;
			}
            var guwens = $('#guwenIf')[0].contentWindow.getGridChecked();
            if(guwens.length==0){
                alert("请选择销售顾问");
                return;
            }

			var memberIds = "";
			$.each(members,function (index,row) {
                memberIds += ","+row.id
            });
            memberIds = memberIds.substr(1);
            var guwenId = guwens[0].id;

            postAsyncFalse("${base}/member/fenpei",{
                memberIds:memberIds,
                guwenId:guwenId
			},function (res) {
                if(res.code==0){
                    alert("操作成功");
                    window.location.reload();
				}else{
                    alert(res.msg);
				}
            });

        }
</script>
<body style="width: 100%;height: 100%">
<div class="layui-container" style="width: 1400px">

	<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
		<legend>批量分配客户至销售顾问</legend>
	</fieldset>

	<div class="layui-row">
		<div class="layui-col-xs5" id="members">

		</div>
		<div class="layui-col-xs2">
			<button  onclick="zhixing()" class="layui-btn layui-btn-lg" style="width: 100%;margin-top: 125px;">执行分配</button>
		</div>
		<div class="layui-col-xs5" id="guwen">

		</div>
	</div>
</div>
</body>
</html>